import 'package:flutter/material.dart';

class LeftDrawer extends StatefulWidget {
  LeftDrawer({Key key}) : super(key: key);

  @override
  _LeftDrawerState createState() => _LeftDrawerState();
}

class _LeftDrawerState extends State<LeftDrawer> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('LeftDrawer'),
        elevation: 0.0,
        automaticallyImplyLeading: false,
      ),
      body: Column(
        children: <Widget>[
          // UserAccountsDrawerHeader 的使用 <效果较固定>
          Row(
            children: <Widget>[
              Expanded(
                child: UserAccountsDrawerHeader(
                  accountName: Text('CoderSun'),
                  accountEmail: Text('123@abc.com'),
                  currentAccountPicture: CircleAvatar(
                    backgroundImage: NetworkImage(
                      'https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1584611795427&di=f73ba48f181a676f609d3fce0fede136&imgtype=0&src=http%3A%2F%2Fb-ssl.duitang.com%2Fuploads%2Fitem%2F201501%2F15%2F20150115142007_MeWWf.jpeg',
                    ),
                  ),
                  decoration: BoxDecoration(
                    color: Colors.yellow,
                    image: DecorationImage(
                      image: NetworkImage(
                        'https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1584611046303&di=f9a8f8f2673fc9b1d8a19e784eb17aad&imgtype=0&src=http%3A%2F%2Fa4.att.hudong.com%2F22%2F59%2F19300001325156131228593878903.jpg',
                      ),
                      fit: BoxFit.cover,
                    ),
                  ),
                  otherAccountsPictures: <Widget>[
                    CircleAvatar(
                      backgroundImage: NetworkImage(
                        'https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1584612603406&di=08e9e60e33127b9aea2679455a199bbe&imgtype=0&src=http%3A%2F%2Fb-ssl.duitang.com%2Fuploads%2Fitem%2F201608%2F28%2F20160828124034_GQrMv.thumb.700_0.jpeg',
                      ),
                    ),
                    CircleAvatar(
                      backgroundImage: NetworkImage(
                        'https://ss0.bdstatic.com/70cFvHSh_Q1YnxGkpoWK1HF6hhy/it/u=1926649153,44242595&fm=11&gp=0.jpg',
                      ),
                    ),
                  ],
                ),
              ),
            ],
          ),

          // DrawerHeader 的使用 <效果灵活 可以自定义>
          // Row(
          //   children: <Widget>[
          //     Expanded(
          //       child: DrawerHeader(
          //         child: Center(
          //           child: Text(
          //             'Header',
          //             style: TextStyle(
          //               fontSize: 50.0,
          //               fontWeight: FontWeight.bold,
          //               color: Colors.white,
          //             ),
          //           ),
          //         ),
          //         decoration: BoxDecoration(
          //             color: Colors.yellow,
          //             image: DecorationImage(
          //               image: NetworkImage(
          //                   'https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1584611046303&di=f9a8f8f2673fc9b1d8a19e784eb17aad&imgtype=0&src=http%3A%2F%2Fa4.att.hudong.com%2F22%2F59%2F19300001325156131228593878903.jpg'),
          //               fit: BoxFit.cover,
          //             )),
          //       ),
          //     ),
          //   ],
          // ),

          ListTile(
            leading: CircleAvatar(
              child: Icon(Icons.mms),
            ),
            title: Text('我的消息'),
          ),
          Divider(height: 1.0, indent: 15.0, endIndent: 15.0),
          ListTile(
            leading: CircleAvatar(
              child: Icon(Icons.settings),
            ),
            title: Text('个人中心'),
            onTap: () {
              // drawer 下的 push
              Navigator.pop(context);
              Navigator.pushNamed(context, '/personalCenter');
            },
          ),
        ],
      ),
    );
  }
}
